package com.lanyeo.liver.util

import android.util.Log
import com.googlecode.tesseract.android.TessBaseAPI
import com.lanyeo.liver.task.TaskResource.Companion.TAG

object Engine {
    val tess = TessBaseAPI()
    fun initTess(bundlePath: String): Boolean {
        tess.setDebug(true)
        if (!tess.init("$bundlePath/", "chi_sim", TessBaseAPI.OEM_LSTM_ONLY)) {
            tess.recycle()
            Log.d(TAG, "tess init fail!")
            return false
        }
        tess.setPageSegMode(TessBaseAPI.PageSegMode.PSM_RAW_LINE)
        return true
    }
    fun destroyTess() {
        tess.recycle()
    }

    val ncnn = NCNN()

    fun initNCNN(bundlePath: String): Boolean {
        return ncnn.createInstance(bundlePath)
    }
    fun destroyNCNN() {
        ncnn.destroy()
    }
}